﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;

namespace Shoozla.ViewModel
{
    class ProgressBarViewModel : ViewModelBase
    {
        public ProgressBarViewModel() { }

        #region commands
        private RelayCommand _CmdCancel;
        public RelayCommand CmdCancel
        {
            get
            {
                if (_CmdCancel == null)
                {
                    _CmdCancel = new RelayCommand(param => DoCmdCancel(), (c) =>
                    {
                        if (App.CurrentAppStatus != App.AppStatus.Idle)
                            return true;
                        else
                            return false;
                    });
                }
                return _CmdCancel;
            }
        }
        #endregion

        #region Do commands
        private void DoCmdCancel()
        {
            if (App.CurrentAppStatus != App.AppStatus.Idle)
            {
                var res = MessageBox.Show("Do you want to stop the operation?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question);
                if (res == MessageBoxResult.Yes)
                    App.StopWorkingThreads();
            }
        }
        #endregion
    }
}
